package br.com.statizo.financeiro.view;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;

public class CalcItemComposite extends Composite{

	public CalcItemComposite(Composite parent, int style) {
		super(parent, style);
	}

	protected String imageName;
	protected String title;
	protected String subTitle;
	protected Color infoColor;
	protected Label valueLabel;
	protected byte type;

	public CalcItemComposite(CalcListComposite parent, String imageName, String title, String subTitle, Color infoColor) {
		super(parent, SWT.NONE);
		this.title = title;
		this.imageName = imageName;
		this.subTitle = subTitle;
		this.infoColor = infoColor;
		createContents();
		//this.type = type;
		
	}


	public void createContents() {

		GridLayout layout = new GridLayout();
		layout.numColumns = 3;
		setLayout(layout);

		setBackground(new Color(Display.getDefault(),255,255,255));
		ImageData imageData = new ImageData(this.getClass().getClassLoader().getResourceAsStream(imageName));
		int whitePixel = imageData.palette.getPixel(new RGB(255,255,255));
		imageData.transparentPixel = whitePixel;
		Image transparentIdeaImage = new Image(Display.getDefault(),imageData);
		

		Label imageComposite = new Label(this, SWT.None);
		imageComposite.setBackground(new Color(Display.getDefault(),255,255,255));
		imageComposite.setSize(22, 22);
		imageComposite.setBackgroundImage(transparentIdeaImage);


		GridData gridData = new GridData();
		gridData.verticalSpan = 2;
		gridData.widthHint = 32;
		gridData.heightHint = 32;
		gridData.horizontalAlignment = SWT.CENTER;
		gridData.verticalAlignment = SWT.CENTER;
		imageComposite.setLayoutData(gridData);

		Label label = new Label(this,SWT.NONE);
		label.setBackground(new Color(Display.getDefault(),255,255,255));
		label.setForeground(infoColor);
		Font font = new Font(Display.getDefault(),"verdana",12,SWT.BOLD);
		label.setFont(font);
		label.setText(title);

		gridData = new GridData();
		label.setLayoutData(gridData);

		valueLabel = new Label(this,SWT.NONE);
		valueLabel.setBackground(new Color(Display.getDefault(),255,255,255));
		valueLabel.setForeground(infoColor);
		font = new Font(Display.getDefault(),"verdana",10,SWT.BOLD);
		valueLabel.setFont(font);
		valueLabel.setText(title);
		valueLabel.setText("Teste 1");
		valueLabel.setAlignment(SWT.RIGHT);
		
		gridData = new GridData();
		gridData.horizontalAlignment = SWT.END;
		gridData.widthHint = 100;
		valueLabel.setLayoutData(gridData);

		label = new Label(this,SWT.NONE);
		label.setBackground(new Color(Display.getDefault(),255,255,255));
		font = new Font(Display.getDefault(),"verdana",10,SWT.NORMAL);
		label.setFont(font);
		label.setText(subTitle);

		gridData = new GridData();
		gridData.grabExcessHorizontalSpace = true;
		label.setLayoutData(gridData);

		
	}




}